-
-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support user context #17
Support user context #17
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
|
I signed it! |
CLAs look good, thanks! |
@yjbanov it's failing on the |
@zoechi was this what you where looking for here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! I most have nitpicks. Design-wise, I'm only curious about making userContext
mutable.
lib/sentry.dart
Outdated
@visibleForTesting | ||
User _userContext; | ||
|
||
set userContext(User val) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We require dartdocs for all public API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
lib/sentry.dart
Outdated
@@ -143,6 +143,13 @@ class SentryClient { | |||
/// Attached to the event payload. | |||
final String projectId; | |||
|
|||
@visibleForTesting | |||
User _userContext; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why opt for a mutable field rather than a final one, like all others?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
lib/sentry.dart
Outdated
@@ -330,6 +342,8 @@ class Event { | |||
/// they must be JSON-serializable. | |||
final Map<String, dynamic> extra; | |||
|
|||
final User userContext; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dartdocs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
lib/sentry.dart
Outdated
/// "email": "[email protected]", | ||
/// "ip_address": "127.0.0.1", | ||
/// "subscription": "basic" | ||
///} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit1: add one space after the ///
nit2: code snippets in dartdocs must be wrapped in triple-backticks, just like on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
lib/sentry.dart
Outdated
final String username; | ||
final String email; | ||
final String ipAddress; | ||
final String subscription; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dartdocs for all public fields. Ideally, link to the docs on sentry.io.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
lib/sentry.dart
Outdated
final String ipAddress; | ||
final String subscription; | ||
|
||
const User(this.id, this.username, this.email, this.ipAddress, this.subscription); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Add dartdocs
- Use named constructor parameters, like the
Event
class - I imagine some of these parameters must be non-null. If so, let's add assertions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
none of them are non-null. The docs say that you must have at least an ID OR an IP Address set. but that is up to the client app to enforce which they want. adding an assert to inform the developer during debug that there might be an issue.
lib/sentry.dart
Outdated
|
||
const User(this.id, this.username, this.email, this.ipAddress, this.subscription); | ||
|
||
Map<String, String> toJson() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dartdocs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@yjbanov Thanks for the review. I'll push an update tomorrow with those fixes. About the mutable |
Ok, I think it makes sense. I suppose in some apps you can switch users dynamically too. So let's keep it mutable. Why don't we just make it a mutable field then? The Dart style guide discourages setters without getters. |
Please ping this PR again when you have the changes finalized and I'll look into the GZIP issue. Recently the Dart standard libraries deprecated ALL_CAPS constant names in favor of camelCase. |
add dart docs for public API replace subscription property with extras map to better match Sentry documentation
@yjbanov I believe I have addressed all the feedback and Travis is now passing. |
'sentry_timestamp=${fakeClock.now().millisecondsSinceEpoch}, ' | ||
'sentry_timestamp=${fakeClock | ||
.now() | ||
.millisecondsSinceEpoch}, ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, did dartfmt
do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it did. it appears that the travis rule runs dartfmt and fails if there is anything changed after running it. so after I ran dartfmt locally and uploaded it now passes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should file a bug.
@yjbanov yes, let's merge and release! thank you. |
Thank you! |
allow the client app to specify a user context for logging events and exceptions to sentry.